package demo.thread;


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author : feixiang.li
 * @since : 2025-09-18 09:38
 */
public class Main {

    public static void main(String[] args) {
        MyThreadPool myThreadPool = new MyThreadPool(2, 4, 1, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2), new ThrowRejectHandle());
        for (int i = 0; i < 6; i++) {
            final  int j = i;
            myThreadPool.execute(() -> {
                try {
                    Thread.sleep(2000);
                    System.out.println("hello world-" + j + Thread.currentThread().getName());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }
        System.out.println("主线程没有被阻塞");
    }
}
